package org.agile2soft.nexoma.ioc;

import org.agile2soft.nexoma.controller.DocumentController;
import org.agile2soft.nexoma.controller.EntryRegController;
import org.agile2soft.nexoma.controller.ExpedientController;
import org.agile2soft.nexoma.controller.ExpedientDocController;
import org.agile2soft.nexoma.controller.ExpedientPhaseController;
import org.agile2soft.nexoma.controller.ExpedientTypeController;
import org.agile2soft.nexoma.controller.ExpedientTypePhaseController;
import org.agile2soft.nexoma.controller.ExpedientTypePhaseExpedientsController;
import org.agile2soft.nexoma.controller.InternalUserController;
import org.agile2soft.nexoma.controller.ProfileController;
import org.agile2soft.nexoma.controller.RequestController;
import org.agile2soft.nexoma.controller.ServiceController;
import org.agile2soft.nexoma.controller.ServiceOptionController;
import org.agile2soft.nexoma.controller.ServicesGroupController;
import org.agile2soft.nexoma.controller.UserController;
import org.agile2soft.nexoma.controller.UserRequestController;
import org.agile2soft.nexoma.controller.impl.DocumentControllerImpl;
import org.agile2soft.nexoma.controller.impl.EntryRegControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientDocControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientPhaseControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientTypeControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientTypePhaseControllerImpl;
import org.agile2soft.nexoma.controller.impl.ExpedientTypePhaseExpedientsControllerImpl;
import org.agile2soft.nexoma.controller.impl.InternalUserControllerImpl;
import org.agile2soft.nexoma.controller.impl.ProfileControllerImpl;
import org.agile2soft.nexoma.controller.impl.RequestControllerImpl;
import org.agile2soft.nexoma.controller.impl.ServiceControllerImpl;
import org.agile2soft.nexoma.controller.impl.ServiceOptionControllerImpl;
import org.agile2soft.nexoma.controller.impl.ServicesGroupControllerImpl;
import org.agile2soft.nexoma.controller.impl.UserControllerImpl;
import org.agile2soft.nexoma.controller.impl.UserRequestControllerImpl;
import org.agile2soft.nexoma.dao.DocumentDAO;
import org.agile2soft.nexoma.dao.EntryRegDAO;
import org.agile2soft.nexoma.dao.ExpedientDAO;
import org.agile2soft.nexoma.dao.ExpedientDocDAO;
import org.agile2soft.nexoma.dao.ExpedientPhaseDAO;
import org.agile2soft.nexoma.dao.ExpedientTypeDAO;
import org.agile2soft.nexoma.dao.ExpedientTypePhaseDAO;
import org.agile2soft.nexoma.dao.ExpedientTypePhaseExpedientsDAO;
import org.agile2soft.nexoma.dao.InternalUserDAO;
import org.agile2soft.nexoma.dao.ProfileDAO;
import org.agile2soft.nexoma.dao.RequestDAO;
import org.agile2soft.nexoma.dao.ServiceDAO;
import org.agile2soft.nexoma.dao.ServiceOptionDAO;
import org.agile2soft.nexoma.dao.ServicesGroupDAO;
import org.agile2soft.nexoma.dao.UserDAO;
import org.agile2soft.nexoma.dao.UserRequestDAO;
import org.agile2soft.nexoma.dao.hibernate.DocumentDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.EntryRegDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientDocDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientPhaseDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientTypeDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientTypePhaseDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ExpedientTypePhaseExpedientsDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.InternalUserDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ProfileDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.RequestDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ServiceDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ServiceOptionDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.ServicesGroupDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.UserDAOImpl;
import org.agile2soft.nexoma.dao.hibernate.UserRequestDAOImpl;
import org.hibernate.SessionFactory;
import org.springframework.config.java.annotation.Bean;
import org.springframework.config.java.annotation.Configuration;
import org.springframework.config.java.annotation.ExternalBean;
import org.springframework.config.java.annotation.Import;
import org.springframework.config.java.annotation.Lazy;

import br.com.arsmachina.dao.hibernate.ioc.PersistenceConfiguration;

/**
 * Main configuration class for Spring JavaConfig. It just imports the other configuration classes.
 *
 * @author Antonio M. Fernandez Rodriguez
 */
@Configuration(defaultLazy = Lazy.TRUE)
@Import( { PersistenceConfiguration.class } )
public class NexomaConfiguration {


    /**
     * Declares a <code>sessionFactory</code> bean, defined elsewhere.
     *
     * @return a {@link SessionFactory}.
     */
    @ExternalBean
    public SessionFactory sessionFactory() {
        return null;
    }

    /**
     * Declares the <code>internalUserDAO</code> bean.
     *
     * @return a {@link InternalUserDAO}.
     */
    @Bean
    public InternalUserDAO internalUserDAO() {
        return new InternalUserDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>userController</code> bean.
     *
     * @return a {@link InternalUserController}.
     */
    @Bean
    public InternalUserController internalUserController() {
        return new InternalUserControllerImpl(internalUserDAO());
    }

    /**
     * Declares the <code>userDAO</code> bean.
     *
     * @return a {@link InternalUserDAO}.
     */
    @Bean
    public UserDAO userDAO() {
        return new UserDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>userController</code> bean.
     *
     * @return a {@link InternalUserController}.
     */
    @Bean
    public UserController userController() {
        return new UserControllerImpl(userDAO());
    }


    /**
     * Declares the <code>service</code> bean.
     *
     * @return a {@link ServiceDAO}.
     */
    @Bean
    public ServiceDAO serviceDAO() {
        return new ServiceDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>serviceController</code> bean.
     *
     * @return a {@link serviceController}.
     */
    @Bean
    public ServiceController serviceController() {
        return new ServiceControllerImpl(serviceDAO());
    }
    /**
     * Declares the <code>service grup</code> bean.
     *
     * @return a {@link ServicesGroupDAO}.
     */
    @Bean
    public ServicesGroupDAO servicesGroupDAO() {
        return new ServicesGroupDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>serviceController</code> bean.
     *
     * @return a {@link serviceController}.
     */
    @Bean
    public ServicesGroupController servicesGroupController() {
        return new ServicesGroupControllerImpl(servicesGroupDAO());
    }


    @Bean
    public ServiceOptionDAO serviceOptionDAO() {
        return new ServiceOptionDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>serviceController</code> bean.
     *
     * @return a {@link serviceController}.
     */
    @Bean
    public ServiceOptionController serviceOptionController() {
        return new ServiceOptionControllerImpl(serviceOptionDAO());
    }
    /**
     * Declares the <code>profile</code> bean.
     *
     * @return a {@link ProfileDAO}.
     */
    @Bean
    public ProfileDAO profileDAO() {
        return new ProfileDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>profileController</code> bean.
     *
     * @return a {@link ProfileController}.
     */
    @Bean
    public ProfileController profileController() {
        return new ProfileControllerImpl(profileDAO());
    }


    /**
     * Declares the <code>entry reg </code>dao  bean.
     *
     * @return a {@link EntryRegDAO}.
     */
    @Bean
    public EntryRegDAO entryRegDAO() {
        return new EntryRegDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>expedientController</code> bean.
     *
     * @return a {@link ExpedientController}.
     */
    @Bean
    public EntryRegController entryRegController() {
        return new EntryRegControllerImpl(entryRegDAO());
    }


    /**
     * Declares the <code>expedient </code>dao  bean.
     *
     * @return a {@link Expedient DAO}.
     */
    @Bean
    public ExpedientDAO expedientDAO() {
        return new ExpedientDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>expedientController</code> bean.
     *
     * @return a {@link ExpedientController}.
     */
    @Bean
    public ExpedientController expedientController() {
        return new ExpedientControllerImpl(expedientDAO());
    }

    /**
     * Declares the <code>expedientDoc </code>dao  bean.
     *
     * @return a {@link ExpedientDoc DAO}.
     */
    @Bean
    public ExpedientDocDAO expedientDocDAO() {
        return new ExpedientDocDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>expedientController</code> bean.
     *
     * @return a {@link ExpedientController}.
     */
    @Bean
    public ExpedientDocController expedientDocController() {
        return new ExpedientDocControllerImpl(expedientDocDAO());
    }

    /**
     * Declares the <code>expedientType</code> dao bean
     *
     * @return a {@link ExpedientTypeDAO}
     */
    @Bean
    public ExpedientTypeDAO expedientTypeDAO() {
        return new ExpedientTypeDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code> expedientController </code bean.
     *
     * @return a {@link ExpedientTypeController}.
     */
    @Bean
    public ExpedientTypeController expedientTypeController() {
        return new ExpedientTypeControllerImpl(expedientTypeDAO());
    }

    /**
     * Declares the <code>expedientTypePhase</code> dao bean
     *
     * @return a {@link ExpedientTypePhaseDAO}.
     */
    @Bean
    public ExpedientTypePhaseDAO expedientTypePhaseDAO() {
        return new ExpedientTypePhaseDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code> expedientController </code> manager bean.
     *
     * @return a {@link ExpedientTypeController}.
     */
    @Bean
    public ExpedientTypePhaseController expedientTypePhaseController() {
        return new ExpedientTypePhaseControllerImpl(expedientTypePhaseDAO());
    }

    /**
     * Declares the <code>expedientTypePhase</code> dao bean
     *
     * @return a {@link ExpedientPhaseDAO}.
     */
    @Bean
    public ExpedientPhaseDAO expedientPhaseDAO() {
        return new ExpedientPhaseDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code> expedientController </code> manager bean.
     *
     * @return a {@link ExpedientTypeController}.
     */
    @Bean
    public ExpedientPhaseController expedientPhaseController() {
        return new ExpedientPhaseControllerImpl(expedientPhaseDAO());
    }
    /****************/
    /**
     * Declares the <code>expedientTypePhase</code> dao bean
     *
     * @return a {@link ExpedientPhaseDAO}.
     */
    @Bean
    public ExpedientTypePhaseExpedientsDAO expedientTypePhaseExpedientsDAO() {
        return new ExpedientTypePhaseExpedientsDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code> expedientController </code> manager bean.
     *
     * @return a {@link ExpedientTypeController}.
     */
    @Bean
    public ExpedientTypePhaseExpedientsController expedientTypePhaseExpedientsController() {
        return new ExpedientTypePhaseExpedientsControllerImpl(expedientTypePhaseExpedientsDAO());
    }

    /**
     * Declares the <code> document</code> dao bean.
     *
     * @return a {@link DocumentDAO}.
     */
    @Bean
    public DocumentDAO documentDAO() {
        return new DocumentDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>documentController</code> bean
     *
     * @return a {@link DocumentController}.
     */
    @Bean
    public DocumentController documentController() {
        return new DocumentControllerImpl(documentDAO());
    }

    /**
     * Declares the <code> request</code> dao bean.
     *
     * @return a {@link RequestDAO}.
     */
    @Bean
    public RequestDAO requestDAO() {
        return new RequestDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>requestController</code> bean
     *
     * @return a {@link RequestController}.
     */
    @Bean
    public RequestController requestController() {
        return new RequestControllerImpl(requestDAO());
    }
    /**
     * Declares the <code>user request</code> dao bean.
     *
     * @return a {@link UserRequestDAO}.
     */
    @Bean
    public UserRequestDAO userRequestDAO() {
        return new UserRequestDAOImpl(sessionFactory());
    }

    /**
     * Declares the <code>requestController</code> bean
     *
     * @return a {@link RequestController}.
     */
    @Bean
    public UserRequestController userRequestController() {
        return new UserRequestControllerImpl(userRequestDAO());
    }
}
